const $axios = require("axios");

$axios.defaults.baseURL = "http://127.0.0.1:8000";
const axios = $axios.create({
  timeout: 5000,
});

axios.interceptors.request.use(
  (config) => {
    config.auth = {
      username: "admin",
      password: "1qaz)PL<",
    };
    return config;
  },
  (error) => {
    console.log(error);
    return Promise.reject();
  }
);

axios.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    console.log(error);
    return Promise.reject();
  }
);

// ---------------------------------------------

// axios
//   .get("/issue/api/id", { params: { conference_id: 3 } })
//   .then((res) => res.data.results)
//   .then((issue) => {
//     axios
//       .get("/advice_attent/viewsets/")
//       .then((res) => res.data.results)
//       .then((advice_attent) =>
//         advice_attent.filter((i) => issue.some((j) => i.issue_id === j.id))
//       )
//       .then((advice_attent) => {
//         axios
//           .get("/danwei/viewsets/")
//           .then((res) => res.data.results)
//           .then((danwei) =>
//             danwei.filter((i) =>
//               advice_attent.some((j) => i.id === j.danwei_id)
//             )
//           )
//           .then((danwei) =>
//             danwei.map((i) => {
//               return {
//                 label: i.name,
//                 value: i.id,
//               };
//             })
//           )
//           .then((danwei) => console.log(danwei));
//       });
//   });


axios.get("/ro_issue/viewsets/", {
  params: {
    reporter:'李娜娜'
  },
})
.then((res) => res.data.results)
.then(data=>console.log(data.filter(i=>i.state!=='完结')))